﻿using System;
using System.Configuration;
using System.IO;
using System.Web.Mvc;
using System.Web.Routing;
using log4net.Config;
using Rhino.Commons.HttpModules;
using WineCellar.Web.Helpers;

namespace WineCellar.Web
{
    public class GlobalApplication : UnitOfWorkApplication
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
            routes.IgnoreRoute("{*alljs}", new {allaspx = @".*\.js(/.*)?"});

            routes.MapRoute("Default", "{controller}/{action}/{id}",new{controller = "Home",action = "Index", id = ""});            
        }

        public override void Application_Start(object sender, EventArgs e)
        {
            base.Application_Start(sender, e);
            XmlConfigurator.Configure();
            ViewEngines.Engines.Clear();
            ViewEngines.Engines.Add(new WineCellarWebFormViewEngine());
            ControllerBuilder.Current.SetControllerFactory(new ControllerFactory());
            RegisterRoutes(RouteTable.Routes);            
        }        
    }
}